package com.cd.works.domain;



import java.util.List;

import org.apache.commons.fileupload.FileItem;

public class Allservice {
	Model model =new Model();
	public int upload(List items) throws Exception {
		System.out.println("Inside upload() of Allservice: ");
		/* FileItem, is the interface, that represents a file or form item that was received
		 * within a multipart/form-data post request
		* The contents of the file are accesed using get() method */
		FileItem fileUpload =(FileItem) items.get(0);
	
		System.out.println("fileupload: "+fileUpload);
		if (fileUpload.getName() == null || fileUpload.getName().length()==0) {
		return -1;
		}
		/*Process the uploaded item*/
		String contentType = fileUpload.getContentType();
		String fileName = fileUpload.getName();
		System.out.println("File Name: "+fileName);
		System.out.println("Content type: "+contentType);
		return model.upload(fileUpload,fileName);
		}
}
